package com.lyf.scm.plan.domain.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;

/**
 * @author Martin
 * @date 2020-11-01 12:14
 */
@Configuration
public class ElasticSearchConfig {

    @Value("${es.planSales.indexPrefix.:scm_plan_sales_}")
    private String planSalesIndexNamePrefix;
    /**
     * 获取预测补货索引
     * @return
     */
    public String getPlanSalesIndexName() {
        LocalDate monday = LocalDate.now().with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
        return planSalesIndexNamePrefix + monday.format(DateTimeFormatter.ofPattern("yyyyMMdd"));
    }
}
